From 04ca4e22abfc21a615b6003ea512fa79dee94cd5 Mon Sep 17 00:00:00 2001
From: PolarStarWalker <savmot1929@gmail.com>
Date: Mon, 2 Jan 2023 02:13:27 +0300
Subject: [PATCH] overlays: i2c-sensor: Add BNO055 IMU sensor

Add support for the Bosch BNO055 9-dof IMU sensor.

Signed-off-by: PolarStarWalker <savmot1929@gmail.com>
Signed-off-by: Phil Elwell <phil@raspberrypi.com>
---
 arch/arm/boot/dts/overlays/README             |  6 ++++
 .../boot/dts/overlays/i2c-sensor-common.dtsi  | 28 ++++++++++++++++++-
 2 files changed, 33 insertions(+), 1 deletion(-)

--- a/arch/arm/boot/dts/overlays/README
+++ b/arch/arm/boot/dts/overlays/README
@@ -2005,6 +2005,9 @@ Params: addr                    Set the
         bmp280                  Select the Bosch Sensortronic BMP280
                                 Valid addresses 0x76-0x77, default 0x76
 
+        bno055                  Select the Bosch Sensortronic BNO055 IMU
+                                Valid address 0x28-0x29, default 0x29
+
         ccs811                  Select the AMS CCS811 digital gas sensor
                                 Valid addresses 0x5a-0x5b, default 0x5b
 
@@ -2071,6 +2074,9 @@ Params: addr                    Set the
                                 incompatible device can stop it from being
                                 activated.
 
+        reset_pin               GPIO to be used to reset the device (bno055
+                                only, disabled by default)
+
         sht3x                   Select the Sensiron SHT3x temperature and
                                 humidity sensor. Valid addresses 0x44-0x45,
                                 default 0x44
--- a/arch/arm/boot/dts/overlays/i2c-sensor-common.dtsi
+++ b/arch/arm/boot/dts/overlays/i2c-sensor-common.dtsi
@@ -2,6 +2,8 @@
 /dts-v1/;
 /plugin/;
 
+#include <dt-bindings/gpio/gpio.h>
+
 / {
 	compatible = "brcm,bcm2835";
 
@@ -455,6 +457,27 @@
 		};
 	};
 
+	fragment@30 {
+		target = <&bno055>;
+		__dormant__ {
+			reset-gpios = <&gpio 5 GPIO_ACTIVE_LOW>;
+		};
+	};
+
+	fragment@31 {
+		target = <&i2cbus>;
+		__dormant__ {
+			#address-cells = <1>;
+			#size-cells = <0>;
+			status = "okay";
+
+			bno055: bno055@29 {
+				compatible = "bosch,bno055";
+				reg = <0x29>;
+			};
+		};
+	};
+
 	__overrides__ {
 		bme280 = <0>,"+0";
 		bmp085 = <0>,"+1";
@@ -487,6 +510,7 @@
 		ms8607 = <0>,"+27";
 		mpu6050 = <0>,"+28";
 		mpu9250 = <0>,"+29";
+		bno055 = <0>,"+31";
 
 		addr =	<&bme280>,"reg:0", <&bmp280>,"reg:0", <&tmp102>,"reg:0",
 			<&lm75>,"reg:0", <&hdc100x>,"reg:0", <&sht3x>,"reg:0",
@@ -494,10 +518,12 @@
 			<&bh1750>,"reg:0", <&mcp980x>,"reg:0", <&jc42>,"reg:0",
 			<&ms5637>,"reg:0", <&ms5803>,"reg:0", <&ms5805>,"reg:0",
 			<&ms5837>,"reg:0", <&ms8607>,"reg:0",
-			<&mpu6050>, "reg:0", <&mpu9250>, "reg:0";
+			<&mpu6050>,"reg:0", <&mpu9250>,"reg:0",
+			<&bno055>,"reg:0";
 		int_pin = <&max30102>, "interrupts:0",
 			<&mpu6050>, "interrupts:0",
 			<&mpu9250>, "interrupts:0";
 		no_timeout = <&jc42>, "smbus-timeout-disable?";
+		reset_pin = <&bno055>,"reset-gpios:4", <0>,"+30";
 	};
 };
